var config = require('../config');
var mongoose = require('mongoose');
var moment = require('moment');

//mongoose
var url = 'mongodb://' + config.host + '/' + config.db;
mongoose.connect(url, {
  user : config.user,
  pass : config.pwd
});

require('../models/user.js');
require('../models/category.js');
require('../models/store.js');
require('../models/question.js');

var User = mongoose.model('User');
var Category = mongoose.model('Category');
var Store = mongoose.model('Store');
var Question = mongoose.model('Question');

Store.find().exec(function(err, ss){

    for(var i = 0 ; i < ss.length; i++){
        var s = ss[i];
        console.log(s);
        for(var j = 0; j < 100; j++){
            new Question({
                store : s,
                text: '第' + i + '-' + j + '题：把大象装进冰箱，需要几步？', //题干
                score : 5, //得分 答对这个题目得多少分
                answer: ['A'], //答案
                opts: [{idx: 'A', text:"3步"}, {idx: "B", text :"2步"}, {idx : "C", text : "4步"}] //选项
            }).save(function(err){
                    if(err) throw err;
                });
        }
    }


});


